﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
using System.Windows.Input;
using System.Windows.Controls;
namespace WPFExcelReport
{
    public partial class TMUL
    {

        public TMUL()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VICC_MULLANG();
            DataContext = MV;
            InitializeComponent();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
            {

            }
            else
            {

            }
        }
        public override void EditCommand(object sender, RoutedEventArgs e)
        {
            try
            {
                base.EditCommand(sender, e);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);

            }
        }

        public override void SaveCommand(object sender, RoutedEventArgs e)
        {
            try
            {
                foreach (DataRow row in TBMain.Rows)
                {
                    TMV.UMUL02(row);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void TextBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key != System.Windows.Input.Key.Enter
                || e.Key != System.Windows.Input.Key.Return)
            {
                return;
            }
            if (dwMaster == null)
                return;
            this.Focus();
            TextBox txt = sender as TextBox;
            TMV.UMUL02(dwMaster);
            vwMaster.View.MoveCurrentToNext();
            txt.Focus();
        }
        public override void LOADBYAUF()
        {
            base.LOADBYAUF();
            TBMain.Clear();
            if (ORDERNUM.Trim().Length == 0)
                return;
            dwData = TBMain.NewRow();
            dwData["MANDANT"] = app.Mandant;
            dwData["MLLOC"] = ORDERNUM;
            if(IsEnOnly)
            {
                dwData["EN"] = " AND EN='EN'";
            }
            SResult = TMV.QMUL02(dwData);
            MergeData(SResult, true);
        }        
    }
}
